﻿using System;

namespace BizElements.Core.ProviderComponents
{
    /// <summary>Provides methods that create generic/default implementation of interfaces for DBMS specific provider components.</summary>
    public static class GenericDbmsComponents
    {
        /// <summary>Gets default/generic implementation of <see cref="IParameterRenderer"/> that uses positional parameters, ie. question marks instead of paramater names.</summary>
        /// <returns>An instance of <see cref="GenericParameterRenderer"/> class.</returns>
        public static IParameterRenderer NewParameterRenderer()
        {
            return new GenericParameterRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IFunctionRenderer"/>.</summary>
        /// <returns>An instance of <see cref="GenericFunctionRenderer"/> class.</returns>
        public static IFunctionRenderer NewFunctionRenderer()
        {
            return new GenericFunctionRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IAggregateFunctionRenderer"/>.</summary>
        /// <returns>An instance of <see cref="GenericAggregateFunctionRenderer"/> class.</returns>
        public static IAggregateFunctionRenderer NewAggregateFunctionRenderer()
        {
            return new GenericAggregateFunctionRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IColumnRenderer"/>. Blanks and special characters are not handled.</summary>
        /// <returns>An instance of <see cref="GenericColumnRenderer"/> class.</returns>
        public static IColumnRenderer NewColumnRenderer()
        {
            return new GenericColumnRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="ITableRenderer"/>. Blanks and special characters are not handled.</summary>
        /// <returns>An instance of <see cref="GenericTableRenderer"/> class.</returns>
        public static ITableRenderer NewTableRenderer()
        {
            return new GenericTableRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IContainsPredicateRenderer"/> that generates compatibile LIKE predicates.</summary>
        /// <returns>An instance of <see cref="ContainsAsLikePredicateRenderer"/> class.</returns>
        public static IContainsPredicateRenderer NewContainsPredicateRenderer()
        {
            return new ContainsAsLikePredicateRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="ILikePredicateRenderer"/>.</summary>
        /// <returns>An instance of <see cref="GenericLikeRenderer"/> class.</returns>
        public static ILikePredicateRenderer NewLikePredicateRenderer()
        {
            return new GenericLikeRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IFromClauseRenderer"/>.</summary>
        /// <returns>An instance of <see cref="GenericFromClauseRenderer"/> class.</returns>
        public static IFromClauseRenderer NewFromClauseRenderer()
        {
            return new GenericFromClauseRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="ISelectRenderer"/> that ignores <see cref="SelectStatement.Top"/> property.</summary>
        /// <returns>An instance of <see cref="GenericSelectRenderer"/> class.</returns>
        public static ISelectRenderer NewSelectRenderer()
        {
            return new GenericSelectRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IUpdater"/> that doesn't use JOINs.</summary>
        /// <returns>An instance of <see cref="GenericUpdater"/> class.</returns>
        public static IUpdater NewUpdater()
        {
            return new GenericUpdater();
        }

        /// <summary>Gets default/generic implementation of <see cref="IDeleteRenderer"/>.</summary>
        /// <returns>An instance of <see cref="GenericDeleteRenderer"/> class.</returns>
        public static IDeleteRenderer NewDeleteRenderer()
        {
            return new GenericDeleteRenderer();
        }

        /// <summary>Gets default/generic implementation of <see cref="IHierarchicalQueryExecutor"/> that issues multiple statements (one per hierarchy level) to manage records at different hierarchy level.</summary>
        /// <returns>An instance of <see cref="GenericHierarchicalQueryExecutor"/> class.</returns>
        public static IHierarchicalQueryExecutor NewHierarchicalQueryExecutor()
        {
            return new GenericHierarchicalQueryExecutor();
        }
    }
}